import Vue from 'vue';
import VueI18n from 'vue-i18n';
import zhHansLocale from './lang/zh-Hans.js';
import enUSLocale from './lang/en.js';

Vue.use(VueI18n);

let lang = uni.getStorageSync("lang")
let sysLang = uni.getStorageSync("sysLang")
if (!sysLang) {
    uni.setStorageSync("sysLang", uni.getLocale());
}
if (!lang || lang == "SYSTEM") {
    lang = uni.getLocale();
    if (!lang) {
        lang = "zh-Hans";
    }
}

Vue.config.lang = lang;

const messages = {
    'zh-Hans': zhHansLocale,
    'en': enUSLocale
};

const i18n = new VueI18n({
    locale: lang,
    messages
});

export default i18n;